# -*- coding: utf-8 -*-

import logging

from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError

from . cfprint_templates import *

_logger = logging.getLogger(__name__)


class BuliaoPrinterConfigSettings(models.TransientModel):

    _name = 'buliao.config.settings'
    _inherit = 'res.config.settings'

    incoming_order_printer = fields.Char(u'入库单')
    plan_order_printer = fields.Char(u'计划单')
    outgoing_order_printer = fields.Char(u'出库单')
    outgoing_order_detail_printer = fields.Char(u'码单')

    incoming_order_rows = fields.Integer(u'入库单')
    plan_order_rows = fields.Integer(u'计划单')
    outgoing_order_rows = fields.Integer(u'出库单')
    outgoing_order_detail_rows = fields.Integer(u'码单')

    @api.multi
    def set_incoming_order_printer_defaults(self):
        # 可以为不同用户指定不同的默认值
        return self.env['ir.values'].sudo().set_default(
            'buliao.config.settings', 'incoming_order_printer', self.incoming_order_printer)

    @api.multi
    def set_plan_order_printer_defaults(self):
        return self.env['ir.values'].sudo().set_default(
            'buliao.config.settings', 'plan_order_printer', self.plan_order_printer)

    @api.multi
    def set_outgoing_order_printer_defaults(self):
        return self.env['ir.values'].sudo().set_default(
            'buliao.config.settings', 'outgoing_order_printer', self.outgoing_order_printer)

    @api.multi
    def set_outgoing_order_detail_printer_defaults(self):
        return self.env['ir.values'].sudo().set_default(
            'buliao.config.settings', 'outgoing_order_detail_printer', self.outgoing_order_detail_printer)

    @api.multi
    def set_incoming_order_rows_defaults(self):
        return self.env['ir.values'].sudo().set_default(
            'buliao.config.settings', 'incoming_order_rows', self.incoming_order_rows)

    @api.multi
    def set_plan_order_rows_defaults(self):
        return self.env['ir.values'].sudo().set_default(
            'buliao.config.settings', 'plan_order_rows', self.plan_order_rows)

    @api.multi
    def set_outgoing_order_rows_defaults(self):
        return self.env['ir.values'].sudo().set_default(
            'buliao.config.settings', 'outgoing_order_rows', self.outgoing_order_rows)

    @api.multi
    def set_outgoing_order_detail_rows_defaults(self):
        return self.env['ir.values'].sudo().set_default(
            'buliao.config.settings', 'outgoing_order_detail_rows', self.outgoing_order_detail_rows)
